package com.cskaoyan.crud;

import com.cskaoyan.bean.User;
import com.cskaoyan.mapper.UserMapper;
import com.cskaoyan.utils.MybatisUtils;
import org.apache.ibatis.session.SqlSession;

/**
 * 创建日期: 2022/10/14 17:13
 *
 * @author ciggar
 */
public class InsertDemo {

    public static void main(String[] args) {

        // 获取SqlSession
        SqlSession sqlSession = MybatisUtils.getSqlSession();

        // 获取接口的代理对象
        UserMapper mapper = sqlSession.getMapper(UserMapper.class);

        // 执行方法
        User user = new User();
        user.setId(3001);
        user.setName("李逵");
        user.setAge(30);
        user.setNickname("黑旋风");
        int affectedRows = mapper.insertUser(user);

        System.out.println(affectedRows);


    }
}
